﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Autofac;
using STX.Lib.Caching;
using STX.Lib.Utils;

namespace ServiceTest
{
    public class BaseTest
    {
        protected IContainer container;

        public BaseTest()
        {
            #region Dependency Injection Here

            var builder = new ContainerBuilder();

            //Register All Service
            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
                .PropertiesAutowired();

            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof (STX.Service.TopicService)))
                .PropertiesAutowired();

            //Register Cache's Provider
            builder.RegisterType<STX.Lib.Caching.Providers.MemoryCacheProvider>().As<ICacheProvider>().SingleInstance();

            //Register Safecode's Provider
            builder.RegisterType<STX.Lib.Security.SessionSafeCodeManager>().As<STX.Lib.Security.ISafeCodeProvider>();

            //Register 
            builder.RegisterType<STX.Repository.EfTransactionContext>().As<STX.Repository.ITransactionContext>();

            container = builder.Build();


            #endregion
        }
    }
}
